package org.lex.game.sudoku.model.visitor;

import java.util.HashSet;
import java.util.Set;

import org.lex.game.sudoku.model.Point;
import org.lex.game.sudoku.model.SudokuModel;

public final class NumberPositionVisitor implements ModelVisitor<Set<Point>> {
	private Set<Point> position = new HashSet<>();

	private final int targetNumber;

	public NumberPositionVisitor(int targetNumber) {
		this.targetNumber = targetNumber;
	}

	@Override
	public VisitResult visit(SudokuModel model, int row, int col, int num) {
		if (num == this.targetNumber) {
			this.position.add(new Point(row, col));
		}
		return VisitResult.CONTINUE;
	}

	@Override
	public Set<Point> finish() {
		return this.position;
	}
}